﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.IO;

namespace SerializeDeserialize
{
    public class GenericFormatter<F> : IGenericFormatter 
                                   where F : IFormatter,new()

    {
       // implement IGenericFormatter by containing an-object based formatter: 
        IFormatter m_Formatter = new F();

        public T Deserialize<T>(Stream serializationStream)
        {
            return (T)m_Formatter.Deserialize(serializationStream);
        }
        public void Serialize<T>(Stream serializationStream, T graph)
        {
            m_Formatter.Serialize(serializationStream, graph);
        }

    }
}
